from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
from meiduo_admin.views import home_views,\
    sku_views,spu_views,user_views,spu_specs_views,\
    spu_specs_options_views,sku_image_views,orders_views,\
    permission_views,permission_group_views,permission_admin_views

urlpatterns = [
    # -------------------------首页部分
    url(r'^authorizations/$',obtain_jwt_token),
    url(r'^statistical/total_count/$',home_views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$',home_views.UserDayIncrementView.as_view()),
    url(r'^statistical/day_active/$',home_views.UserDayActiveView.as_view()),
    url(r'^statistical/day_orders/$',home_views.UserDayOrdersView.as_view()),
    url(r'^statistical/month_increment/$',home_views.UserMonthIncrementView.as_view()),
    url(r'^statistical/goods_day_views/$',home_views.UserGoodsDayView.as_view()),

    #-------------------------用户部分
    url(r'^users/$',user_views.UserView.as_view()),

    # -------------------------商品sku部分
    # url(r'^skus/$',views.SKUView.as_view({"get":"list"}))
    url(r'^skus/categories/$',sku_views.SKUCategoryView.as_view()),
    url(r'^goods/simple/$',sku_views.GoodSimpleView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$',sku_views.SPUSpecsView.as_view()),

    # -------------------------商品spu部分
    url(r'^goods/brands/simple/$', spu_views.SPUView.as_view({"get":"brand"})),
    url(r'^goods/channel/categories/$', spu_views.SPUView.as_view({"get":"category"})),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spu_views.SPUView.as_view({"get":"category_sub"})),
    url(r'^goods/images/$', spu_views.SPUView.as_view({"post":"upload_image"})),

    # -------------------------商品spu specs option部分
    url(r'^goods/specs/simple/$',spu_specs_options_views.SPUSpecView.as_view()),

    # -------------------------商品sku image部分
    url(r'^skus/simple/$',sku_image_views.SKUImageView.as_view({"get":"sku_simple"})),

    # -------------------------商品订单部分
    # url(r'^orders/$',orders_views.OrdersView.as_view()),
    # url(r'^orders/(?P<pk>\d+)/$',orders_views.OrderView.as_view()),
    # url(r'^orders/(?P<pk>\d+)/status/$',orders_views.OrdersReadOnlyView.as_view({"put":"status"})),

    # -------------------------权限部分
    url(r'^permission/content_types/$',permission_views.PermissionContentTypeView.as_view()),

    # -------------------------用户权限组部分
    url(r'^permission/simple/$',permission_group_views.PermissionGroupSimpleView.as_view()),

    # -------------------------管理员部分
    url(r'^permission/groups/simple/$',permission_admin_views.PermissionGroupSimpleView.as_view())
]

#
# -------------------------管理员部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'permission/admins',permission_admin_views.PermissionAdminView,base_name="admins")
#3,添加路由到urlpatterns
urlpatterns += router.urls


# -------------------------用户权限组部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'permission/groups',permission_group_views.PermissionGroupView,base_name="permission")
#3,添加路由到urlpatterns
urlpatterns += router.urls

# -------------------------权限部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'permission/perms',permission_views.PermissionView,base_name="permission")
#3,添加路由到urlpatterns
urlpatterns += router.urls


# -------------------------商品订单部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'orders',orders_views.OrdersReadOnlyView,base_name="orders")
#3,添加路由到urlpatterns
urlpatterns += router.urls

#/skus/images/
# -------------------------商品sku image部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'skus/images',sku_image_views.SKUImageView,base_name="specs")
#3,添加路由到urlpatterns
urlpatterns += router.urls

# -------------------------商品spu specs option部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'specs/options',spu_specs_options_views.SPUSpecsOptionsSpecView,base_name="specs")
#3,添加路由到urlpatterns
urlpatterns += router.urls


# -------------------------商品spu specs部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'goods/specs',spu_specs_views.SPUSpecView,base_name="specs")
#3,添加路由到urlpatterns
urlpatterns += router.urls

# -------------------------商品spu部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'goods',spu_views.SPUView,base_name="spus")
#3,添加路由到urlpatterns
urlpatterns += router.urls


# -------------------------商品sku部分
#1,创建路由
router = DefaultRouter()
#2,注册视图集
router.register(r'skus',sku_views.SKUView,base_name="skus")
#3,添加路由到urlpatterns
urlpatterns += router.urls